package com.coderg.gmall.order.controller;

import com.coderg.gmall.common.result.Result;
import com.coderg.gmall.model.enums.OrderStatus;
import com.coderg.gmall.order.service.OrderInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description
 * @Author CoderG
 * @Date 2025/6/10 22:18
 **/
@RestController
@RequestMapping("/api/order")
public class OrderController {
    @Autowired
    OrderInfoService orderInfoService;
    @GetMapping(value = "/addOrder")
    public Result addOrder(){
        orderInfoService.addOrder();
        return Result.ok();
    }

    /**
     * 取消订单
     * @param id
     */
    @GetMapping(value = "/addOrder/{id}")
    public Result cancelOrder(@PathVariable("id") Long id){
        orderInfoService.cancelOrder(id, OrderStatus.CANCEL.getComment());
        return Result.ok();
    }
}
